package SingletonThread;

public class LazyInitialization {
    public int num = 10;
    private static volatile LazyInitialization instance;
    private static final Object locker = new Object();
    private LazyInitialization() {
    }
    public static LazyInitialization getInstance(){
        if (instance == null){
            synchronized (locker) {
                if (instance == null) {
                    instance = new LazyInitialization();
                }
            }
        }
        return instance;
    }
    public void doSomething() {
        System.out.println("数字："+num);
    }
}